import 'package:cloudbase_database/cloudbase_database.dart';

class ShoeModel {
  Null code;
  Null message;
  List<ShoeModelData> data;
  String requestId;
  Null total;
  int limit;
  int offset;

  ShoeModel(
      {this.code,
      this.message,
      this.data,
      this.requestId,
      this.total,
      this.limit,
      this.offset});

  ShoeModel.fromJson(DbQueryResponse json) {
    code = json.code;
    message = json.message;
    if (json.data != null) {
      List<ShoeModelData> arr = [];
      json.data.forEach((v) {
        var map = new Map<String, dynamic>.from(v);
        arr.add(new ShoeModelData.fromJson(map));
      });
      data = arr;
    }
    requestId = json.requestId;
    total = json.total;
    limit = json.limit;
    offset = json.offset;
  }

  // ShoeModel.fromJson(Map<String, dynamic> json) {
  //   code = json['code'];
  //   message = json['message'];
  //   if (json['data'] != null) {
  //     List<ShoeModelData> data = [];
  //     json['data'].forEach((v) {
  //       data.add(new ShoeModelData.fromJson(v));
  //     });
  //   }
  //   requestId = json['requestId'];
  //   total = json['total'];
  //   limit = json['limit'];
  //   offset = json['offset'];
  // }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['code'] = this.code;
    data['message'] = this.message;
    if (this.data != null) {
      data['data'] = this.data.map((v) => v.toJson()).toList();
    }
    data['requestId'] = this.requestId;
    data['total'] = this.total;
    data['limit'] = this.limit;
    data['offset'] = this.offset;
    return data;
  }
}

class ShoeModelData {
  int iCreateTime;
  String sId;
  int iUpdateTime;
  String brand;
  String content;
  List<String> imgs;
  double price;
  String title;
  String color;
  int count;

  ShoeModelData(
      {this.iCreateTime,
      this.sId,
      this.iUpdateTime,
      this.brand,
      this.content,
      this.imgs,
      this.price,
      this.title,
      this.color,
      this.count});

  ShoeModelData.fromJson(Map<String, dynamic> json) {
    iCreateTime = json['_createTime'];
    sId = json['_id'];
    iUpdateTime = json['_updateTime'];
    brand = json['brand'];
    content = json['content'];
    imgs = json['imgs'].cast<String>();
    price = double.parse(json['price'].toString());
    title = json['title'];
    color = json['color'];
    count = json['count'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['_createTime'] = this.iCreateTime;
    data['_id'] = this.sId;
    data['_updateTime'] = this.iUpdateTime;
    data['brand'] = this.brand;
    data['content'] = this.content;
    data['imgs'] = this.imgs;
    data['price'] = this.price;
    data['title'] = this.title;
    data['color'] = this.color;
    data['count'] = this.count;
    return data;
  }
}


// class ShoeModel {
//   final String name;
//   final double price;
//   final String desc;
//   final Color color;
//   final String brand;
//   final String imgPath;

//   ShoeModel({
//     this.name,
//     this.price,
//     this.desc,
//     this.color,
//     this.brand,
//     this.imgPath,
//   });

//   static List<ShoeModel> list = [
//     ShoeModel(
//       name: "Nike Air Jordan 1 Retro High",
//       desc:
//           "Familiar but always fresh, the iconic Air Jordan 1 is remastered for today's sneakerhead culture. This Retro High OG version goes all in with full-grain leather, comfortable cushioning and classic design details.",
//       price: 184,
//       color: AppColors.blueColor,
//       brand: "Nike",
//       imgPath: "2.png",
//     ),
//     ShoeModel(
//       name: "Converse X OPI Chuck Taylor",
//       desc:
//           "Familiar but always fresh, the iconic Air Jordan 1 is remastered for today's sneakerhead culture. This Retro High OG version goes all in with full-grain leather, comfortable cushioning and classic design details.",
//       price: 123,
//       color: AppColors.yellowColor,
//       brand: "Converse",
//       imgPath: "1.png",
//     ),
//     ShoeModel(
//       name: "Nike Air Jordan 1 Retro High",
//       desc:
//           "Familiar but always fresh, the iconic Air Jordan 1 is remastered for today's sneakerhead culture. This Retro High OG version goes all in with full-grain leather, comfortable cushioning and classic design details.",
//       price: 135,
//       color: AppColors.redColor,
//       brand: "Nike",
//       imgPath: "3.png",
//     ),
//   ];
// }
